﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Repository.Interface
{
    /// <summary>
    /// 数据库操作
    /// </summary>
    public interface IBaseRepository
    {
        List<TEntity> SelectList<TEntity>();

        /*
        /// <summary>
        /// 添加数据(实体模式)
        /// </summary>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="model">插入的数据</param>
        /// <returns></returns>
        Task<bool> InsertData<TEntity>(TEntity model) where TEntity : class, new();
        /// <summary>
        /// 添加数据集(实体模式)
        /// </summary>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="model">插入的数据</param>
        /// <returns></returns>
        Task<bool> InsertDatas<TEntity>(List<TEntity> model) where TEntity : class, new();
        /// <summary>
        /// 添加数据(json数组模式)
        /// </summary>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="recordList">待添加数据列表</param>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        Task<bool> InsertData<TEntity>(List<Dictionary<string, object>> recordList, string tableName);
        /// <summary>
        /// 添加数据(json模式)
        /// </summary>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="record">待添加数据</param>
        /// <param name="tableName">表名</param>
        /// <returns></returns>
        Task<bool> InsertData<TEntity>(Dictionary<string, object> record, string tableName);
        /// <summary>
        /// 查询单条数据
        /// </summary>
        /// <typeparam name="TEntity">数据库实体</typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="whereExpression">查询条件</param>
        /// <returns></returns>
        Task<TEntity> QueryData<TEntity>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderby = null, OrderByType orderByType = 0);
        /// <summary>
        /// 查询数据列表
        /// </summary>
        /// <typeparam name="TEntity">数据库实体</typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="whereExpression">查询条件</param>
        /// <returns></returns>
        Task<List<TEntity>> QueryDataList<TEntity>(Expression<Func<TEntity, bool>> whereExpression, Expression<Func<TEntity, object>> orderby = null, OrderByType orderByType = OrderByType.Asc);
        /// <summary>
        /// 查询指定值
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="where">查询条件</param>
        /// <param name="column">目标值</param>
        /// <returns></returns>
        Task<string> QueryValue<TEntity>(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, string>> column);
        /// <summary>
        /// 查询指定值 分组模式
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connectionStrings"></param>
        /// <param name="where"></param>
        /// <param name="column"></param>
        /// <param name="group"></param>
        /// <returns></returns>
        Task<List<string>> QueryValueGroup<TEntity>(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, string>> column, Expression<Func<TEntity, object>> group, Expression<Func<TEntity, object>> orderby = null, OrderByType orderByType = OrderByType.Asc);
        /// <summary>
        /// 查询指定值集合
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="where">查询条件</param>
        /// <param name="column">目标值</param>
        /// <returns></returns>
        Task<List<string>> QueryValues<TEntity>(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, string>> column);
        /// <summary>
        /// 更新指定数据
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="model">数据实体</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        Task<bool> UpdateData<TEntity>(TEntity model, Expression<Func<TEntity, bool>> where) where TEntity : class, new();
        /// <summary>
        /// 更新指定数据 忽略某些字段
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="model">数据实体</param>
        /// <param name="where">条件</param>
        /// <param name="IgnoreColumn">要忽略的字段</param>
        /// <returns></returns>
        Task<bool> UpdateData<TEntity>(TEntity model, Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, object>> IgnoreColumn) where TEntity : class, new();
        /// <summary>
        /// 更新指定数据 如果目标列不存在 则为插入本条数据
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="model">数据实体</param>
        /// <param name="where">更新条件</param>
        /// <param name="column">目标列</param>
        /// <returns></returns>
        Task<bool> UpdateData<TEntity>(TEntity model, Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, string>> column) where TEntity : class, new();
        /// <summary>
        /// 更新数据（json数组模式）
        /// </summary>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="recordList">待添加数据列表</param>
        /// <param name="tableName">表名</param>
        /// <param name="whereColumns">更新条件键名</param>
        /// <returns></returns>
        Task<bool> UpdateData<TEntity>(List<Dictionary<string, object>> recordList, string tableName, string whereColumns);
        /// <summary>
        /// 更新数据（json模式）
        /// </summary>
        /// <param name="connectionStrings">要连接的数据库</param>
        /// <param name="record">待添加数据</param>
        /// <param name="tableName">表名</param>
        /// <param name="whereColumns">更新条件键名</param>
        /// <returns></returns>
        Task<bool> UpdateData<TEntity>(Dictionary<string, object> record, string tableName, string whereColumns);
        */
    }
}
